package com.server.common;

/**
 * Description: This is a sample class.
 * @Author Simon
 */


import com.server.model.enums.ExceptionInfo;

/**
 * 返回工具类
 */
public class HttpResultUtil {

    /**
     * 成功
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> HttpBaseResponse<T> success(T data) {
        return new HttpBaseResponse<>(0, data, "ok");
    }

    /**
     * 失败
     *
     * @param errorCode
     * @return
     */
    public static HttpBaseResponse error(ExceptionInfo errorCode) {
        return new HttpBaseResponse<>(errorCode);
    }

    /**
     * 失败
     *
     * @param code
     * @param message
     * @return
     */
    public static HttpBaseResponse error(int code, String message) {
        return new HttpBaseResponse(code, null, message);
    }

    /**
     * 失败
     *
     * @param errorCode
     * @return
     */
    public static HttpBaseResponse error(ExceptionInfo errorCode, String message) {
        return new HttpBaseResponse(errorCode.getCode(), null, message);
    }
}
